<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - src/caffe/solvers/adagrad_solver.cpp</title>
  <link rel="stylesheet" type="text/css" href="../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../index.html">top level</a> - <a href="index.html">src/caffe/solvers</a> - adagrad_solver.cpp<span style="font-size: 80%;"> (source / <a href="adagrad_solver.cpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntry">15</td>
            <td class="headerCovTableEntryLo">13.3 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:25:26</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntry">6</td>
            <td class="headerCovTableEntryLo">33.3 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #include &lt;vector&gt;</a>
<span class="lineNum">       2 </span>            : 
<span class="lineNum">       3 </span>            : #include &quot;caffe/sgd_solvers.hpp&quot;
<span class="lineNum">       4 </span>            : 
<span class="lineNum">       5 </span>            : namespace caffe {
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : #ifndef CPU_ONLY
<span class="lineNum">       8 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">       9 </span>            : void adagrad_update_gpu(int N, Dtype* g, Dtype* h, Dtype delta,
<span class="lineNum">      10 </span>            :     Dtype local_rate);
<span class="lineNum">      11 </span>            : #endif
<a name="12"><span class="lineNum">      12 </span>            : </a>
<span class="lineNum">      13 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      14 </span><span class="lineNoCov">          0 : void AdaGradSolver&lt;Dtype&gt;::ComputeUpdateValue(int param_id, Dtype rate) {</span>
<span class="lineNum">      15 </span>            :   const vector&lt;Blob&lt;Dtype&gt;*&gt;&amp; net_params = this-&gt;net_-&gt;learnable_params();
<span class="lineNum">      16 </span>            :   const vector&lt;float&gt;&amp; net_params_lr = this-&gt;net_-&gt;params_lr();
<span class="lineNum">      17 </span><span class="lineNoCov">          0 :   Dtype delta = this-&gt;param_.delta();</span>
<span class="lineNum">      18 </span><span class="lineNoCov">          0 :   Dtype local_rate = rate * net_params_lr[param_id];</span>
<span class="lineNum">      19 </span><span class="lineNoCov">          0 :   switch (Caffe::mode()) {</span>
<span class="lineNum">      20 </span>            :   case Caffe::CPU: {
<span class="lineNum">      21 </span>            :     // compute square of gradient in update
<span class="lineNum">      22 </span><span class="lineNoCov">          0 :     caffe_powx(net_params[param_id]-&gt;count(),</span>
<span class="lineNum">      23 </span>            :         net_params[param_id]-&gt;cpu_diff(), Dtype(2),
<span class="lineNum">      24 </span>            :         this-&gt;update_[param_id]-&gt;mutable_cpu_data());
<span class="lineNum">      25 </span>            : 
<span class="lineNum">      26 </span>            :     // update history
<span class="lineNum">      27 </span><span class="lineNoCov">          0 :     caffe_add(net_params[param_id]-&gt;count(),</span>
<span class="lineNum">      28 </span>            :         this-&gt;update_[param_id]-&gt;cpu_data(),
<span class="lineNum">      29 </span>            :         this-&gt;history_[param_id]-&gt;cpu_data(),
<span class="lineNum">      30 </span>            :         this-&gt;history_[param_id]-&gt;mutable_cpu_data());
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            :     // prepare update
<span class="lineNum">      33 </span><span class="lineNoCov">          0 :     caffe_powx(net_params[param_id]-&gt;count(),</span>
<span class="lineNum">      34 </span>            :               this-&gt;history_[param_id]-&gt;cpu_data(), Dtype(0.5),
<span class="lineNum">      35 </span>            :               this-&gt;update_[param_id]-&gt;mutable_cpu_data());
<span class="lineNum">      36 </span>            : 
<span class="lineNum">      37 </span><span class="lineNoCov">          0 :     caffe_add_scalar(net_params[param_id]-&gt;count(),</span>
<span class="lineNum">      38 </span>            :               delta, this-&gt;update_[param_id]-&gt;mutable_cpu_data());
<span class="lineNum">      39 </span>            : 
<span class="lineNum">      40 </span><span class="lineNoCov">          0 :     caffe_div(net_params[param_id]-&gt;count(),</span>
<span class="lineNum">      41 </span>            :               net_params[param_id]-&gt;cpu_diff(),
<span class="lineNum">      42 </span>            :               this-&gt;update_[param_id]-&gt;cpu_data(),
<span class="lineNum">      43 </span>            :               this-&gt;update_[param_id]-&gt;mutable_cpu_data());
<span class="lineNum">      44 </span>            : 
<span class="lineNum">      45 </span>            :     // scale and copy
<span class="lineNum">      46 </span><span class="lineNoCov">          0 :     caffe_cpu_axpby(net_params[param_id]-&gt;count(), local_rate,</span>
<span class="lineNum">      47 </span>            :         this-&gt;update_[param_id]-&gt;cpu_data(), Dtype(0),
<span class="lineNum">      48 </span>            :         net_params[param_id]-&gt;mutable_cpu_diff());
<span class="lineNum">      49 </span>            :     break;
<span class="lineNum">      50 </span>            :   }
<span class="lineNum">      51 </span>            :   case Caffe::GPU: {
<span class="lineNum">      52 </span>            : #ifndef CPU_ONLY
<span class="lineNum">      53 </span>            :     adagrad_update_gpu(net_params[param_id]-&gt;count(),
<span class="lineNum">      54 </span>            :         net_params[param_id]-&gt;mutable_gpu_diff(),
<span class="lineNum">      55 </span>            :         this-&gt;history_[param_id]-&gt;mutable_gpu_data(), delta, local_rate);
<span class="lineNum">      56 </span>            : #else
<span class="lineNum">      57 </span><span class="lineNoCov">          0 :     NO_GPU;</span>
<span class="lineNum">      58 </span>            : #endif
<span class="lineNum">      59 </span>            :     break;
<span class="lineNum">      60 </span>            :   }
<span class="lineNum">      61 </span>            :   default:
<span class="lineNum">      62 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Unknown caffe mode: &quot; &lt;&lt; Caffe::mode();</span>
<span class="lineNum">      63 </span>            :   }
<span class="lineNum">      64 </span><span class="lineNoCov">          0 : }</span>
<a name="65"><span class="lineNum">      65 </span>            : </a>
<span class="lineNum">      66 </span>            : INSTANTIATE_CLASS(AdaGradSolver);
<a name="67"><span class="lineNum">      67 </span><span class="lineCov">          3 : REGISTER_SOLVER_CLASS(AdaGrad);</span></a>
<span class="lineNum">      68 </span>            : 
<span class="lineNum">      69 </span><span class="lineCov">          3 : }  // namespace caffe</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
